package org.kumas.bigdata.hdfs3.fsdirectory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArrayList;

/*************************************************
 * TODO_Kumas
 *  Author： KumasZhang
 *  DateTime： 2021-12-02 8:27
 *  Description： 目录结构抽象
 **/
public class INodeDirectory extends INode{
    private List<INode> children = new CopyOnWriteArrayList<>();

    public INodeDirectory(String name, INode parent) {
        super(name, parent);
    }

    @Override
    public final boolean isDirectory() {
        return true;
    }

    @Override
    public final INodeDirectory asDirectory() {
        return this;
    }

    // TODO_Kumas 注释： 返回只读列表
    List<INode> getChildrenList() {
        return Collections.unmodifiableList(children);
    }

    public void addChild(INode child) {
        children.add(child);
    }
}
